home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14374 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  81 lines

  1. Path: news.flex.com.au!news
  2. From: cobweb@flex.com.au (Tony L)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help Please
  5. Date: Sat, 30 Mar 1996 03:48:03 GMT
  6. Organization: Flex Information Technology
  7. Message-ID: <4ji7eo$kgm@daisy.flex.com.au>
  8. NNTP-Posting-Host: slip1-8.flex.com.au
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi all,
  12.  
  13. I have this prog that I can't get to do a simple IF condition
  14. properly.  I just want it to say "You have voted for Paul Keating" if
  15. the user enters Paul Keating.  Yeah!  I know, stupid idea for a
  16. program  :-))) 
  17.  
  18. When I enter Paul Keating or not, it says "You didn't vote for Paul
  19. Keating" even if I did enter "Paul Keating"
  20.  
  21. Could someone please help me with it....
  22.  
  23. it is as follows:
  24.  
  25. #include <conio.h>
  26. #include <stdio.h>
  27.  
  28. main()
  29. {
  30.     int age;
  31.     int yrs;
  32.     char him[] = "Keating";
  33.     char first[15], last[15];
  34.     char first2[15], last2[15];
  35.  
  36.     clrscr();
  37.     printf("                               The Voting Booth!");
  38.     printf("\n\nWhat is your first name please? ");
  39.     scanf(" %s", first);
  40.     printf("\nWhat is your last name please? ");
  41.     scanf("  %s", last);
  42.  
  43.     printf("\nHow old are you please? ");
  44.     scanf(" %d", &age);
  45.     if (age < 18)
  46.         { printf("You are too YOUNG to vote!!!!\n\a\a\a");
  47.         yrs = 18 - age;
  48.         printf("You can vote in %d years.\n", yrs); }
  49.     else
  50.     { printf("\nCongratulations! you are old enough to vote!\n"); }
  51.     printf("\nWho would you like to vote for? ");
  52.     printf("\n\nWhat is their first name please? ");
  53.     scanf(" %s", first2);
  54.     printf("\nWhat is their last name please? ");
  55.     scanf("  %s", last2);
  56.     if (last2 == him)
  57.         { printf("you have voted for Paul Keating!"); }
  58.     else
  59.     { printf("\nYou didn't vote for Paul Keating!");  }
  60.  
  61.     printf("\n\nHere is the Info you entered:\n\n");
  62.     printf("Name: %s %s\n", first, last);
  63.     printf("Age: %d", age);
  64.     printf("\nYou Voted for: %s %s\n", first2, last2);
  65.     return 0;
  66. }
  67.  
  68. Thank you very much for your time....
  69.  
  70.  
  71.  Ciao,
  72.  TonyL....
  73.  
  74.  *---------------------------------*
  75.  E-mail: cobweb@flex.com.au
  76.          lamborghini@acslink.net.au
  77.  URL:    http://www.peg.apc.org/~lamborghini
  78.  Mobile: 0419 255 830    +61 419 255 830
  79.  *-------------------------------------------*
  80.  
  81.